<# # It is recommended to test the script on a local machine for its purpose and effects. # Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description: Script to fetch Events details based on the Event ID provided # Configuration Type - Computer # Arguments: EventID1 EventID2 EventID3 # Example : 2 200 100 #> # Check if arguments are provided if ($args.Length -eq 0) { Write-Host "No event IDs provided. Please provide event IDs as arguments." exit } # Specify the event IDs to filter using command line arguments $eventIDs = $args # Retrieve events from all available event logs $eventLogs = Get-WinEvent -ListLog * -ErrorAction SilentlyContinue foreach ($eventID in $eventIDs) { $eventFound = $false Write-Host "Checking for Event ID: $eventID" $eventLogs | ForEach-Object { $events = Get-WinEvent -LogName $_.LogName -FilterXPath "*[System/EventID=$eventID]" -ErrorAction SilentlyContinue # Check if any events were found if ($events) { $eventFound = $true Write-Host "Event $eventID exists in log $($_.LogName)" } } if (-not $eventFound) { Write-Host "Event $eventID does not exist in any log." } }